'\" te
.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH DDI_INTR_GET_NINTRS 9F "Dec 13, 2013"
.SH NAME
ddi_intr_get_nintrs, ddi_intr_get_navail \- return number of interrupts
supported or available for a given interrupt type
.SH SYNOPSIS
.nf
#include <sys/types.h>
#include <sys/conf.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>

\fBint\fR \fBddi_intr_get_nintrs\fR(\fBdev_info_t *\fR\fIdip\fR, \fBint\fR \fItype\fR, \fBint *\fR\fInintrsp\fR);
.fi

.LP
.nf
\fBint\fR \fBddi_intr_get_navail\fR(\fBdev_info_t *\fR\fIdip\fR, \fBint\fR \fItype\fR, \fBint *\fR\fInavailp\fR);
.fi

.SH INTERFACE LEVEL
illumos DDI specific (illumos DDI).
.SH PARAMETERS
\fBddi_intr_get_nintrs()\fR
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 11n
Pointer to \fBdev_info\fR structure
.RE

.sp
.ne 2
.na
\fB\fItype\fR\fR
.ad
.RS 11n
Interrupt type
.RE

.sp
.ne 2
.na
\fB\fInintrsp\fR\fR
.ad
.RS 11n
Pointer to number of interrupts of the given type that are supported by the
system
.RE

.sp
.LP
\fBddi_intr_get_navail()\fR
.sp
.ne 2
.na
\fB\fIdip\fR\fR
.ad
.RS 11n
Pointer to \fBdev_info\fR structure
.RE

.sp
.ne 2
.na
\fB\fItype\fR\fR
.ad
.RS 11n
Interrupt type
.RE

.sp
.ne 2
.na
\fB\fInavailp\fR\fR
.ad
.RS 11n
Pointer to number of interrupts of the given type that are currently available
from the system
.RE

.SH DESCRIPTION
The \fBddi_intr_get_nintrs()\fR function returns the number of interrupts of
the given \fItype\fR supported by a particular hardware device. On a successful
return, the number of supported interrupts is returned as an integer pointed to
by the \fInintrsp\fR argument.
.sp
.LP
If the hardware device is not found to support any interrupts of the given
\fItype\fR, the \fBDDI_INTR_NOTFOUND\fR failure is returned rather than a zero
in \fInintrsp\fR.
.sp
.LP
The \fBddi_intr_get_navail()\fR function returns the number of interrupts of a
given \fItype\fR that is available to a particular hardware device. On a
successful return, the number of available interrupts is returned as an integer
pointed to by \fInavailp\fR.
.sp
.LP
The hardware device may support more than one interrupt and can request that
all interrupts be allocated. The host software can then use policy-based
decisions to determine how many interrupts are made available to the device.
Based on the determination, a value is returned that should be used to allocate
interrupts with the \fBddi_intr_alloc()\fR function.
.sp
.LP
The \fBddi_intr_get_supported_types\fR(9F) function returns a list of valid
supported types for the given hardware device. It must be called prior to
calling either the \fBddi_intr_get_nintrs()\fR or \fBddi_intr_get_navail()\fR.
.SH RETURN VALUES
The \fBddi_intr_get_nintrs()\fR and \fBddi_intr_get_navail()\fR functions
return:
.sp
.ne 2
.na
\fB\fBDDI_SUCCESS\fR\fR
.ad
.RS 21n
On success.
.RE

.sp
.ne 2
.na
\fB\fBDDI_EINVAL\fR\fR
.ad
.RS 21n
On encountering invalid input parameters.
.RE

.sp
.ne 2
.na
\fB\fBDDI_INTR_NOTFOUND\fR\fR
.ad
.RS 21n
On not finding any interrupts for the given interrupt type.
.RE

.sp
.ne 2
.na
\fB\fBDDI_FAILURE\fR\fR
.ad
.RS 21n
On any implementation specific failure.
.RE

.SH CONTEXT
The \fBddi_intr_get_nintrs()\fR and \fBddi_intr_get_navail()\fR functions can
be called from either user or kernel non-interrupt context.
.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Committed
.TE

.SH SEE ALSO
.BR attributes (7),
.BR ddi_intr_alloc (9F),
.BR ddi_intr_enable (9F),
.BR ddi_intr_get_supported_types (9F)
.sp
.LP
\fIWriting Device Drivers\fR
.SH NOTES
The \fBddi_intr_get_nintrs()\fR and \fBddi_intr_get_navail()\fR functions can
be called at any time, even if the driver has added an interrupt handler for a
given interrupt specification.
.sp
.LP
On x86 platforms, the number of interrupts returned by the
\fBddi_intr_get_navail()\fR function might need to be further reduced by the
number of interrupts available for each interrupt priority on the system. In
that case, drivers should use different priorities for some of the interrupts.
.sp
.LP
Consumers of these interfaces should verify that the return value is not equal
to \fBDDI_SUCCESS\fR. Incomplete checking for failure codes could result in
inconsistent behavior among platforms.
